Skip to content

Values ​

Conversion ​

ConvertJsonToTable ​

lua
json_table = ConvertJsonToTable(json_str)

Converts a JSON string to a table.

Parameters ​

ParameterTypeDescription
json_strStringJSON string

Return Value ​

Return ValueTypeDescription
json_tableTableData table

Example ​

Assume the value of json_str is:

json
{
  "recipe": [
    {
      "pin": 1,
      "PinHeight": 7.95
    },
    {
      "pin": 2,
      "PinHeight": 7.95
    }
  ]
}

Then the content of the output json_table is:

lua
json_table = {
  recipe = {
    {
      pin = 1,
      PinHeight = 7.95
    },
    {
      pin = 2,
      PinHeight = 7.95
    }
  }
}

ConvertTableToJson ​

lua
json_str = ConvertTableToJson(json_table)

Converts a table to a JSON string.

Parameters ​

ParameterTypeDescription
json_tableTableData table

Return Value ​

Return ValueTypeDescription
json_strStringJSON string

Example ​

Assume the value of json_table is:

lua
json_table = {
  recipe = {
    {
      pin = 1,
      PinHeight = 7.95
    },
    {
      pin = 2,
      PinHeight = 7.95
    }
  }
}

Then the content of the output json_str is:

json
{
  "recipe": [
    {
      "pin": 1,
      "PinHeight": 7.95
    },
    {
      "pin": 2,
      "PinHeight": 7.95
    }
  ]
}

HMI Data ​

WriteHmiData ​

lua
success = WriteHmiData(table_name, fields, values)

Writes data to the HMI database. Fields in fields correspond one-to-one with values in values.

Parameters ​

ParameterTypeDescription
table_nameStringName of the database table
fieldsArrayList of field names (content is strings)
valuesArrayList of values

Return Value ​

Return ValueTypeDescription
successBoolWhether the operation is successful

Global Variables ​

SetBoolVariable ​

lua
SetBoolVariable(name, variable)

Sets a global variable (Boolean type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableBoolValue of the variable

SetStringVariable ​

lua
SetStringVariable(name, variable)

Sets a global variable (String type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableStringValue of the variable

SetIntVariable ​

lua
SetIntVariable(name, variable)

Sets a global variable (Integer type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableIntegerValue of the variable

SetFloatVariable ​

lua
SetFloatVariable(name, variable)

Sets a global variable (Float type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableNumber (Double-precision Float)Value of the variable

SetBoolArrayVariable ​

lua
SetBoolArrayVariable(name, variable)

Sets a global variable (Boolean Array type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableArrayValue of the variable

SetStringArrayVariable ​

lua
SetStringArrayVariable(name, variable)

Sets a global variable (String Array type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableArrayValue of the variable

SetIntArrayVariable ​

lua
SetIntArrayVariable(name, variable)

Sets a global variable (Integer Array type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableArrayValue of the variable

SetFloatArrayVariable ​

lua
SetFloatArrayVariable(name, variable)

Sets a global variable (Float Array type).

Parameters ​

ParameterTypeDescription
nameStringName of the global variable
variableArrayValue of the variable

Script Output ​

SetInt ​

lua
SetInt(name, n)

Sets an integer to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
nIntInteger value

SetFloat ​

lua
SetFloat(name, f)

Sets a float to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
fFloatFloat value

SetBool ​

lua
SetBool(name, b)

Sets a Boolean value to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
bBoolBoolean value

SetString ​

lua
SetString(name, str)

Sets a string to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
strStringString value

SetMatrix ​

lua
SetMatrix(name, rows, cols, data)

Sets a matrix to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
rowsIntNumber of rows in the matrix
colsIntNumber of columns in the matrix
dataArrayMatrix data (represented in row-major order)

SetIntArray ​

lua
SetIntArray(name, array)

Sets an integer array to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
arrayArrayInteger array

SetFloatArray ​

lua
SetFloatArray(name, array)

Sets a float array to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
arrayArrayFloat array

SetBoolArray ​

lua
SetBoolArray(name, array)

Sets a Boolean array to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
arrayArrayBoolean array

SetStringArray ​

lua
SetStringArray(name, array)

Sets a string array to the script output.

Parameters ​

ParameterTypeDescription
nameStringName of the output variable
arrayArrayString array

AI-Vision, Making 3D Measurement Easier